const router = require('koa-router')()
const { getToken, Addurl } = require('../../config/databaseapi.js')
// 添加帖子接口
router.post('/addtopic', async (ctx) => {
  console.log("调用添加帖子接口");
  console.log(ctx.request.body);
  const res = await new getToken().posteve(Addurl, `db.collection("topic").add({data:${JSON.stringify(ctx.request.body)}})`);
  if (res.errcode === 0) {
    ctx.body = { msg: "添加成功", status: 1 }
  } else {
    ctx.body = { msg: "添加失败", status: 0 }
  }
})

module.exports = router.routes()